﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VideoClassLibrary.Extension;
using VideoClassLibrary.Model;
using VideoClassLibrary.BusinessLogicLayer;
public partial class ClassRoomManagement_SVR_IPC_Management_AddSVRInfo : System.Web.UI.Page
{
    public int SVRID = 0;
    public  SVR_IPC_Module svr = new SVR_IPC_Module();
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!string.IsNullOrEmpty(Request.QueryString["SVRID"]))
        {
            SVRID=int.Parse(Request.QueryString["SVRID"].ToString());
            if (!this.IsPostBack)
            {
                bindSVRInfo();
            }
           
        }
    }

    private void bindSVRInfo()
    {
        SVR_IPC_Module svr = new SVR_IPC_Module();
        SVRInfo_Table SVRInfo = svr.GetSVRInfoModel(SVRID);
        this.txtSVRName.Value = SVRInfo.SVRName;
        this.txtSVRIP.Value = SVRInfo.SVRIP;
        this.txtSVRPort.Value = SVRInfo.SVRPort.ToString();
        this.txtSVRUser.Value = SVRInfo.SVRUser;
        this.txtSVRPwd.Value = SVRInfo.SVRPwd;
        this.ddlSVRStatus.SelectedValue = SVRInfo.SVRStatus.ToString();
        
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        SVRInfo_Table model = new SVRInfo_Table();
        model.SVRName = this.txtSVRName.Value;
        model.SVRIP = this.txtSVRIP.Value;
        if (!string.IsNullOrEmpty(this.txtSVRPort.Value))
        {
            if (StringUtils.IsNumeric(txtSVRPort.Value))
            {
                model.SVRPort = int.Parse(this.txtSVRPort.Value);
            }
        }else
        {
            model.SVRPort = 0;
        }
        model.SVRUser = this.txtSVRUser.Value;
        model.SVRPwd = this.txtSVRPwd.Value;
        model.SVRStatus = int.Parse(ddlSVRStatus.SelectedValue);
        if (SVRID > 0)
        {
            model.SVRID = SVRID;
            svr.UpdateSVRInfo(model);
            PageHelper.AlterMsgAndRedirect("修改成功", "SVRConfigurationList.aspx");
        }
        else
        {
            svr.AddSVRInfo(model);
            PageHelper.AlterMsgAndRedirect(" 添加成功", "SVRConfigurationList.aspx");
        }

    }
}
